# include <cstdio>
# include <algorithm>
# include <iostream>
# define MAXN 15023
using namespace std;

inline char gc() { 
    static char buf[1 << 18], *fs, *ft;
    return (fs == ft && (ft = (fs = buf) + fread(buf, 1, 1 << 18, stdin)), fs == ft) ? EOF : *fs++;
}

inline int gn() { 
    register char c;
    int k = 0, f = 1;
    c = gc();
    for(; !isdigit(c); c = gc()) if(c == '-') f = -1;
    for(; isdigit(c); c = gc()) k = k * 10 + c - '0';
    return k * f;
}

int dis, y, n, m;
int a[MAXN], b[MAXN], c[MAXN], d[MAXN];
int h[40003], w[MAXN];

int main() { 
    freopen("magicb.in", "r", stdin);
    freopen("magicb.out", "w", stdout);
    n = gn(), m = gn();
    for(int i = 1; i <= m; i++) w[h[i] = gn()]++;
    for(int i = 1; i <= n / 9; i++) {               // i = CD
        dis = 8 * i + 1;                            // dis = AC
        y = 0;
        for(int j = n - 9 * i; j; j--) {            // j = A
            y += w[j + dis] * w[j + dis + i];       // j + dis = C  j + dis + i = D
            a[j] += y * w[j + (i << 1)];            // j + (i << 1) = B
            b[j + (i << 1)] += y * w[j];
        }
        dis = 9 * i + 1;                            // dis = AD
        y = 0;
        for(int j = dis + 1; j <= n; j++) {         // j = D
            y += w[j - dis] * w[j - dis + (i << 1)];
            c[j - i] += y * w[j];
            d[j] += y * w[j - i];
        }
    }
    for(int i = 1; i <= m; i++) printf("%d %d %d %d\n", a[h[i]], b[h[i]], c[h[i]], d[h[i]]);
}
